package com.jcz.daoImpl;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.jcz.dao.HibernateUtil;
import com.jcz.dao.Vote_UserDao;
import com.jcz.entity.Vote_User;

public class Vote_UserDaoImpl implements Vote_UserDao {

	/*登陆方法*/
	@Override
	public Vote_User login(Vote_User user) {
		Session session=null;
		Vote_User user2=null;
		
		try {
			session=HibernateUtil.currentSession();
			Criteria criteria=session.createCriteria(Vote_User.class);
			criteria.add(Restrictions.eq("vu_user_id", user.getVu_user_id()));
			criteria.add(Restrictions.eq("vu_user_password", user.getVu_user_password()));
			user2=(Vote_User)criteria.uniqueResult();
			/*user2=(Vote_User)session.createQuery("select u from Vote_User u "+"where u.vu_user_id=:id and u.vu_user_password=:pwd")
					.setParameter("id", user.getVu_user_id())
					.setParameter("pwd", user.getVu_user_password())
					.uniqueResult();*/
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return user2;
	}

}
